<?php

/**
 * Erra_Persistance_Sql : IO class for database access
 *
 * @package
 * @author Alexis Eric
 * @copyright Copyright (c) 2012 - Erra Prod, Erra Studios
 * @version $1.0$
 * @access public
 */
abstract class Erra_Persistance_PersistanceUnit {

    /**
     * Erra_Persistance_PersistanceUnit::saveField() : Saves fields in database
     *
     * @param mixed $field : The field you want to save
     * @return
     */
    public static function saveField($field) {
        $sqlTableSaver = new Erra_Persistance_SqlTable();
        $sqlTableSaver->saveFieldToDatabase($field);
    }

    /**
     * Erra_Persistance_PersistanceUnit::getFieldFromSQL() : Gets fields from MySQL
     *
     * @param mixed $fieldName : The field you want to extract from base
     * @param string $OPTIONAL_WHERE_CLAUSE : Optional clause eg: "WHERE column='value'"
     * @param mixed $fieldBuildingArguments : $buildArgs to construct field
     * @return
     */
    public static function getFieldFromSQL($field, $OPTIONAL_WHERE_CLAUSE = null) {
        $sqlTableSaver = new Erra_Persistance_SqlTable();
        $sqlTableSaver->getFieldFromDatabase($field, $OPTIONAL_WHERE_CLAUSE);
        // FIXME TRICK
        $field->postInit();

        return $field;
    }

}

?>